package logobj;
import logobj.config.ConfProperties;
import logobj.dao.LogDao;
import logobj.dataAnalysis.AnalysisNew;
import logobj.ftpUtil.analysis.AnalysisFtp;
import logobj.utils.OutLog;
import java.util.ArrayList;
import java.util.Map;

public class App {
    public static void main( String[] args ) {
        OutLog.printf("==============加载配置文件，初始化系统！==============");
        Loading.init();
        LogDao logDao = new LogDao();
        Map<String, ArrayList> fineinfomap = null;
        AnalysisFtp analysisFtp = null;
        while (true){
            OutLog.printf("==============开始入库数据！==============");
            if("N".equals(ConfProperties.no_ftp_model.toUpperCase())){
                analysisFtp = new AnalysisFtp();
                fineinfomap = analysisFtp.startFtp();
                analysisFtp = null;
                if(fineinfomap.get("namelist").size() == 0){
                    OutLog.printf("本次检测FTP文件夹无日志数据！");
                }
                System.gc();
            }else {
                OutLog.printf("已禁用ftp下载！");
            }

            if("Y".equals(ConfProperties.trunca_tetable_status.toUpperCase())  ){
                OutLog.printf("清除数据库数据！");
                logDao.clearTable();
            }
            AnalysisNew analysisNew = new AnalysisNew();
            analysisNew.inputData(ConfProperties.ftp_localpath);
            System.gc();
            OutLog.printf("==============本次执行完毕！==============");
            try {
                Thread.sleep(1000 * ConfProperties.file_insertdb_interval_time );
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }



}
